<template>
  <view class="container">
    <rich-text :nodes="detail"></rich-text>
  </view>
</template>

<script setup>
import {
  onLoad
} from '@dcloudio/uni-app';
import {
  ref
} from 'vue';
import api from '@/api/index.js';

const detail = ref('');

// 获取用户注册协议和隐私政策
const getAdvDetail = id => {
  api.base.getAdvDetail({ id: id }).then(res => {
    if (res.code == 1) {
      uni.setNavigationBarTitle({
        title: res.data.title
      });
      detail.value = res.data.main_content.replace(new RegExp('src="', 'g'), `style="max-width:100%!important;" src="`);
    } else {
      uni.showToast({
        title: res.msg,
        icon: 'none'
      });
    }

  });
}

onLoad(options => {

  getAdvDetail(options.id);
});
</script>

<style lang="less" scoped>
page {
  background: #fff;
}

.container {
  padding: 32rpx;
}
</style>